var posx = line.length - curx + 1; // Column position in string.
if (curx == 1) { // IF cursor at start-of-line,
// ed.command("ecLeft"); // move to end of previous line. PM: this command was replaced by the two commands bellow
if (cury > 1) { // PM: if not on first line
ed.command("ecUp"); // PM: move cursor up
ed.command("ecLineEnd"); // PM: and to the end of line
}
} else if (curx > line.length+1) { // PM: if beyond end of line
ed.command("ecLineEnd"); // PM: move cursor to the end of line
} else { // ELSE find next CTRL+LEFT stop
line = line.reverse(); // Reverse the text to leverage CTRL-RIGHT logic. PM: moved from beginning of the function to here, no need to run it every time
var c = line.charAt((posx + trim));
if (c == '$') { // CURSOR ON $:
trim++; // move over $.
} else
if (c.match(white)) { // CURSOR ON WHITE SPACE:
trim +=
count((line.slice(posx + trim)), white); // move over white spaces,
trim +=
count((line.slice(posx + trim)), alpha); // move over alphas.
var c = line.charAt((posx + trim));
} else
if (c.match(delim)) { // CURSOR ON DELIMITER:
trim +=
count((line.slice(posx + trim)), delim); // move over delimiters,
} else
if (c.match(alpha)) { // CURSOR ON ALPHANUMERIC:
trim +=
count((line.slice(posx + trim)), alpha); // move over alphanumerics,
}
curx = curx - trim; // Account for trimmed chars.
ed.caretX(curx); // Reposition cursor.
} // IF (cursor at start-of-line)
return;
}
function ueCSR()
{
/* UltraEdit/TextPad [ CTRL+SHIFT+RIGHT ] cursor
behavior: move and select tax through next
right-context cursor stop.
*/
constructEditor(); // Construct editor obj, etc.
var posx = curx - 1; // String pos begins at 0, cursor begins at column 1.
if (curx >= line.length) { // If cursor at end-of-line,
// ed.command("ecSelRight"); // continue selection to start of next line. PM: command replaced
ed.command("ecSelDown"); // PM: Move selection to the next line
ed.command("ecSelLineStart"); // PM: Move selection to the begging of the line
} else { // ELSE find next CTRL+RIGHT stop
var c = line.charAt((posx + trim));
if (c.match(white)) { // CURSOR ON WHITE SPACE:
trim +=
count((line.slice(posx + trim)), white); // move over white spaces,
var c = line.charAt((posx + trim));
if (c == '$') { // move over $ trailing whites.
trim++;
}
} else
if (c.match(delim)) { // CURSOR ON DELIMITER:
trim +=
count((line.slice(posx + trim)), delim); // move over delimiters,
c = line.charAt((posx + trim));
trim +=
count((line.slice(posx + trim)), white); // move over white space trailing delims,
c = line.charAt((posx + trim));
if (c == '$') { // move over $ trailing whites.
trim++;
}
} else
if (c.match(alpha)) { // CURSOR ON ALPHANUMERIC:
trim +=
count((line.slice(posx + trim)), alpha); // move over alphanumerics,
c = line.charAt((posx + trim));
trim +=
count((line.slice(posx + trim)), white); // move over white space trailing alphas,
c = line.charAt((posx + trim));
if (c == '$') { // move over $ trailing whites.
trim++;
}
}
for (n=0; n < trim; n++) { // Position cursor by
ed.command("ecSelRight"); // selecting each trim char.
}
}
return;
}
function ueCSL()
{
/* UltraEdit/TextPad [ CTRL+SHIFT+LEFT ] cursor
behavior: move and select tax through next
left-context cursor stop.
*/
constructEditor(); // Construct editor obj, etc.
var posx = line.length - curx + 1; // Column position in string.
if (curx == 1) { // If cursor at start-of-line,
// ed.command("ecSelLeft"); // continue selection to end of previous line. PM: Command replaced
if (cury > 1) { // PM: If not on first line
ed.command("ecSelUp"); // PM: move selection on line up
ed.command("ecSelLineEnd"); // PM: and to the end of line
}
} else if (curx > line.length+1) { // PM: if beyond end of line
ed.command("ecSelLineEnd"); // PM: move selection to the end of line
} else { // ELSE find next CTRL+LEFT stop
line = line.reverse(); // Reverse the text so as to reuse CTRL-RIGHT logic. PM: moved from beginning of the function to here, no need to run it every time
var c = line.charAt( (posx + trim) );
if (c == '$') { // CURSOR ON $:
trim++; // move over $.
} else
if (c.match(white)) { // CURSOR ON WHITE SPACE:
trim +=
count((line.slice(posx + trim)), white); // move over white spaces,
trim +=
count((line.slice(posx + trim)), alpha); // move over alphas.
var c = line.charAt( (posx + trim) );
} else
if (c.match(delim)) { // CURSOR ON DELIMITER:
trim +=
count((line.slice(posx + trim)), delim); // move over delimiters,
} else
if (c.match(alpha)) { // CURSOR ON ALPHANUMERIC:
trim +=
count((line.slice(posx + trim)), alpha); // move over alphanumerics,
}
for (n=0; n < trim; n++) { // Position cursor by
ed.command("ecSelLeft"); // selecting each trim char.
}
} // IF (cursor at start-of-line)
return;
}
function about()
{
/* Extension description, how to use, license,
open source project web address, and developer
credits.
*/
echo(
"\n" + module_name + " " + module_ver + "\n\n" +
"_________________\n" +
"DESCRIPTION\n\n" +
" PSPad Editor extension to enhance native\n" +
" cursor behavior.\n" +
"_________________\n" +
"USE\n\n" +
" [ CTRL+RIGHT ] and [ CTRL+LEFT ] move the\n" +
" cursor to the next right/left-context stop.\n\n" +
" [ SHIFT+CTRL+RIGHT ] and [ SHIFT+CTRL+LEFT ]\n" +
" select text with each move.\n" +
"_________________\n" +
"CREDITS\n\n" +
" www.sf.net/projects/ingkcpos\n\n" +
" MIT License\n" +
" Copyright (c) July 2007 Damion HΣnkejh, ingk.com\n" +